package org.d7_buffered_stream;

import java.io.*;

public class BufferedReadTest2 {
    public static void main(String[] args) throws IOException {
        try(
                Reader fr = new FileReader("D:\\idea\\idea code\\java-practice\\practice\\change\\file-oi-app\\src\\test\\d7test1.txt");
                //1。定义一个字节缓冲输入流包装原始的字节输入流
              BufferedReader br = new BufferedReader(fr);

        ) {
//
//            char[] buffer = new char[3];
//            int len;
//            while ((len = br.read(buffer))!= -1){
//                System.out.print(new String(buffer,0,len));
//            }

//            System.out.println(br.readLine());
//            System.out.println(br.readLine());
//            System.out.println(br.readLine());
//            System.out.println(br.readLine());
//            System.out.println(br.readLine());
//            System.out.println(br.readLine());//没有内容返回null

            //优化：
            String line;  //记住每一行数据
            while ((line = br.readLine()) != null){
                System.out.println(line);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
